Core::IDocumentFactory Class
class Core::IDocumentFactoryThe IDocumentFactory class is used to open files that are not opened in an editor. More...
| Header: | #include <coreplugin/idocumentfactory.cpp> |
Public Functions
| IDocumentFactory() | |
| void | addMimeType(const QString &mimeType) |
| void | addMimeType(const char *mimeType) |
| bool | isProjectFactory() const |
| bool | isUsedForOpenFile() const |
| QStringList | mimeTypes() const |
| Core::IDocument * | open(const Utils::FilePath &filePath) |
| void | setIsProjectFactory(bool isProjectFactory) |
| void | setMimeTypes(const QStringList &mimeTypes) |
| void | setOpener(const Core::IDocumentFactory::Opener &opener) |
| void | setUsedForOpenFile(bool usedForOpenFile) |
Detailed Description
When users open a document, the document factory responsible for the corresponding MIME type is determined by checking the mimeTypes() of the factories.
Document factories that are project factories are not considered if the user specifically requests to open a file, unless they are used for opening files.
See also setMimeTypes(), addMimeType(), setIsProjectFactory(), setUsedForOpenFile(), and setOpener().
Member Function Documentation
IDocumentFactory::IDocumentFactory()
Creates a new document factory.
void IDocumentFactory::addMimeType(const QString &mimeType)
Adds the MIME type with name mimeType to the list of mime types that this factory can open.
void IDocumentFactory::addMimeType(const char *mimeType)
Adds the mimeType to the list of mime types that this factory can open.
bool IDocumentFactory::isProjectFactory() const
Returns whether this factory is used to open projects.
Defaults to false.
See also setIsProjectFactory().
bool IDocumentFactory::isUsedForOpenFile() const
Returns whether this factory is considered when the user requests to open a file.
Defaults to true for factories that are not project factories, and to false for those that are.
See also setUsedForOpenFile().
QStringList IDocumentFactory::mimeTypes() const
Returns the list of mime types that this factory can open.
See also setMimeTypes() and addMimeType().
Core::IDocument *IDocumentFactory::open(const Utils::FilePath &filePath)
Opens the file at filePath.
This uses the opener function set by setOpener() to open the file. Returns the document that was opened or nullptr if an error occurred.
See also setOpener().
void IDocumentFactory::setIsProjectFactory(bool isProjectFactory)
Sets whether this factory is used to open projects to isProjectFactory.
Factories that are not used to open projects are considered when the user triggers File > Open File.
See also isProjectFactory().
void IDocumentFactory::setMimeTypes(const QStringList &mimeTypes)
Sets the mimeTypes that this factory can open.
See also mimeTypes().
void IDocumentFactory::setOpener(const Core::IDocumentFactory::Opener &opener)
Sets the opener function that is called to open a file.
void IDocumentFactory::setUsedForOpenFile(bool usedForOpenFile)
Sets whether this factory is considered when the user requests to open a file to usedForOpenFile.
This is for project factories that open something that cannot be opened in an editor, such as a directory.
See also isUsedForOpenFile().